<?php

class Application_Form_DodajPrzesylka extends Zend_Form
{

    public function init()
    {
        $this->setMethod('post');
        
        $id_nadawca = $this->createElement('text', 'id_nad');
        $id_nadawca->setLabel('Identyfikator nadawcy(podaj w celu sprawdzenia statusu przesyłki):')
                ->setRequired(TRUE)
                ->setAttrib('rows', 3)
                ->setAttrib('cols', 50)
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                    new Zend_Filter_StripNewlines(),
                    new Zend_Filter_StripTags()
                ))
                ->addValidators(array(
                    new Zend_Validate_StringLength(2)
                ));
        $this->addElement($id_nadawca);
        
        $nadawca = $this->createElement('textarea', 'nadawca');
        $nadawca->setLabel('Nadawca przesyłki:')
                ->setRequired(TRUE)
                ->setAttrib('rows', 3)
                ->setAttrib('cols', 50)
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                    new Zend_Filter_StripNewlines(),
                    new Zend_Filter_StripTags()
                ))
                ->addValidators(array(
                    new Zend_Validate_StringLength(3)
                ));
        $this->addElement($nadawca);

        $adresat = $this->createElement('text', 'odbiorca');
        $adresat->setLabel('Odbiorca przesyłki:')
                ->setRequired(TRUE)
                ->setAttrib('rows', 3)
                ->setAttrib('cols', 50)
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                    new Zend_Filter_StripNewlines(),
                    new Zend_Filter_StripTags()
                ));
        $this->addElement($adresat);
        
        $adres = $this->createElement('text', 'adres');
        $adres->setLabel('Adres:')
                ->setRequired(TRUE)
                ->setAttrib('rows', 3)
                ->setAttrib('cols', 50)
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                    new Zend_Filter_StripNewlines(),
                    new Zend_Filter_StripTags()
                ));
        $this->addElement($adres);
        
        $miasto = $this->createElement('text', 'miasto');
        $miasto->setLabel('Miasto:')
                ->setRequired(TRUE)
                ->setAttrib('rows', 3)
                ->setAttrib('cols', 50)
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                    new Zend_Filter_StripNewlines(),
                    new Zend_Filter_StripTags()
                ));
        $this->addElement($miasto);


        $waga = $this->createElement('text', 'waga');
        $waga->setLabel('Waga przesyłki:')
                ->setRequired(TRUE)
                ->setAttrib('size', 30)
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                    new Zend_Filter_StripNewlines(),
                    new Zend_Filter_StripTags()
                ));
        $this->addElement($waga);
        
        $wysokosc = $this->createElement('text', 'wysokosc');
        $wysokosc->setLabel('Wysokosc przesyłki:')
                ->setRequired(TRUE)
                ->setAttrib('size', 30)
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                    new Zend_Filter_StripNewlines(),
                    new Zend_Filter_StripTags()
                ));
        $this->addElement($wysokosc);
        
        $szerokosc = $this->createElement('text', 'szerokosc');
        $szerokosc->setLabel('Szerokosc przesyłki:')
                ->setRequired(TRUE)
                ->setAttrib('size', 30)
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                    new Zend_Filter_StripNewlines(),
                    new Zend_Filter_StripTags()
                ));
        $this->addElement($szerokosc);
        
        $glebokosc = $this->createElement('text', 'glebokosc');
        $glebokosc->setLabel('Glebokosc przesyłki:')
                ->setRequired(TRUE)
                ->setAttrib('size', 30)
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                    new Zend_Filter_StripNewlines(),
                    new Zend_Filter_StripTags()
                ));
        $this->addElement($glebokosc);

        $paczka = $this->createElement('select', 'id_rodz_pacz');
        $paczka->setLabel('Rodzaj paczki:')
                ->setRequired(TRUE)
                ->addValidators(array(
                    new Zend_Validate_NotEmpty(),
                    new Zend_Validate_Alnum()));

        $paczki = new Application_Model_PaczkaMapper();
        $results = new Application_Model_Paczka();
        $results = $paczki->podajPaczki();

        foreach($results as $kier)
        {
            $paczka->addMultiOption($kier->getIdRodzPacz(), $kier->getNazwa());
        }
        $this->addElement($paczka);

        $pobranie = $this->createElement('text', 'pobranie');
        $pobranie->setLabel('Kwota pobrania:')
                ->setRequired(TRUE)
                ->setAttrib('size', 30)
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                    new Zend_Filter_StripNewlines(),
                    new Zend_Filter_StripTags()
                ));
        $this->addElement($pobranie);

        $this->addElement('submit', 'submit', array(
            'ignore' => true,
            'label' => 'Dodaj',
                ));
    }

}
